package text1;

import java.io.*;


public class CopyDome {
    /**
     * 复制粘贴
     * @param args
     */
    public static void main(String[] args) {
        /**
         * 第一步：找到你要复制的路径
         * 第二步：复制
         */
        String str = "D:\\123.txt";
        String srt = "D:\\Path\\新建文件夹 (7)\\365.txt";
        boolean b = copyD(str, srt);
        System.out.println(b ? "操作成功" : "操作失败");
    }

    public static boolean copyD(String str,String srt){
        try (
                InputStream in = new FileInputStream(str);
                OutputStream ou = new FileOutputStream(srt);
                ){
            byte[] bytes = new byte[1024];
            int i;
            while ((i = in.read(bytes)) != -1){
                    ou.write(bytes,0,i);
            }
            return true;

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false;
    }
}
